package attend

import (
	"io"
	"log"

	"net/http"

	"awfan.cn/utils"
	"gopkg.in/mgo.v2"
	"gopkg.in/mgo.v2/bson"
)

func create(w http.ResponseWriter, body []byte,db *mgo.Database)() {

	data := COMPANY_XML{}

	err := json.Unmarshal(body, &data)

	if err != nil {
		return nil, &utils.RESP_ERROR{404, err}
	}

	data.Id = bson.NewObjectId()
	data.Created_time = utils.Now()

	c := db.C(utils.PkgName(COMPANIES_XML{}))

	err = c.Insert(&data)

	if err != nil {

		return nil, &utils.RESP_ERROR{404, err}
	}

	return "{}", nil
}
